/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package perception;

import java.awt.Point;

/**
 *
 * @author Benjamin
 */
public class PerceptionNonMarkov extends Perception {

    private boolean leftSideOstacle;
    private boolean rightSideOstacle;
    private boolean upSideOstacle;
    private boolean downSideOstacle;

    public PerceptionNonMarkov(PerceptionNonMarkov perceptionNM) {
    }

    public PerceptionNonMarkov(maze.SituatedAgent a) {
        setAgent(a);
        updatePerception();
    }

    public PerceptionNonMarkov() {
    }

    @Override
    public void updatePerception() {
        _position = getAgent().getPosition();

        this.leftSideOstacle = getAgent().getMaze().isThereABrickHere(new Point((int) _position.getX() - 1, (int) _position.getY()));
        this.rightSideOstacle = getAgent().getMaze().isThereABrickHere(new Point((int) _position.getX() + 1, (int) _position.getY()));
        this.upSideOstacle = getAgent().getMaze().isThereABrickHere(new Point((int) _position.getX(), (int) _position.getY() - 1));
        this.downSideOstacle = getAgent().getMaze().isThereABrickHere(new Point((int) _position.getX(), (int) _position.getY() + 1));
    }

    @Override
    public PerceptionNonMarkov copy() {
        PerceptionNonMarkov plp = new PerceptionNonMarkov();
        plp._position = new Point(_position);

        plp.leftSideOstacle = this.leftSideOstacle;
        plp.rightSideOstacle = this.rightSideOstacle;
        plp.upSideOstacle = this.upSideOstacle;
        plp.downSideOstacle = this.downSideOstacle;

        plp.setAgent(getAgent());
        return plp;
    }

    @Override
    public void display() {
    }

    @Override
    public boolean equals(Perception s) {
        PerceptionNonMarkov ss = (PerceptionNonMarkov) s;

        return (this.leftSideOstacle == ss.isLeftSideOstacle()
                && this.rightSideOstacle == ss.isRightSideOstacle()
                && this.upSideOstacle == ss.isUpSideOstacle()
                && this.downSideOstacle == ss.isDownSideOstacle());
    }

    public boolean isDownSideOstacle() {
        return downSideOstacle;
    }

    public boolean isLeftSideOstacle() {
        return leftSideOstacle;
    }

    public boolean isRightSideOstacle() {
        return rightSideOstacle;
    }

    public boolean isUpSideOstacle() {
        return upSideOstacle;
    }

    public void setDownSideOstacle(boolean downSideOstacle) {
        this.downSideOstacle = downSideOstacle;
    }

    public void setLeftSideOstacle(boolean leftSideOstacle) {
        this.leftSideOstacle = leftSideOstacle;
    }

    public void setRightSideOstacle(boolean rightSideOstacle) {
        this.rightSideOstacle = rightSideOstacle;
    }

    public void setUpSideOstacle(boolean upSideOstacle) {
        this.upSideOstacle = upSideOstacle;
    }
}
